﻿#region 命名空间

using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using WinnerCMS.Model;
using WinnerCMS.Data;

#endregion

namespace WinnerCMS.BLL
{
    /// <summary>
    /// 字段控制
    /// </summary>
    public static class FieldControl
    {
        /// <summary>
        /// 是否启用－－自动取得ModelId
        /// </summary>
        /// <param name="field"></param>
        /// <returns></returns>
        public static bool Enabale(string field)
        {
            byte modelId = byte.Parse(HttpContext.Current.Request["ModelId"]);
            var model = ModelManage.GetInfo(modelId);

            foreach (string str in model.Filter.Split(';'))
            {
                string[] arr = str.Split('|');

                if (arr.Length < 2)
                {
                    continue;
                }

                if (arr[0].Length == 0 || arr[1].ToLower() != field.ToLower())
                {
                    continue;
                }

                if (arr.Length != 3)
                {
                    return false;
                }
                return bool.Parse(arr[2]);
            }
            return false;
        }
    }
}